#ifndef FILESERVER_H
#define FILESERVER_H

#include <QObject>
#include <QTcpServer>
#include <QTcpSocket>
#include <QFile>
#include <QMap>
#include <global_client.h>

/**
 * @brief The FileServer class
 * 文件接收任务类
 */
class FileServer : public QObject
{
    Q_OBJECT
public:
    explicit FileServer(QObject *parent = nullptr);
    ~FileServer();

    bool startServer(quint16 port);

private slots:
    void onNewConnection();
    void onReadyRead();
    void onDisconnected();
signals:
    /**
     * @brief onGettingFile
     * @param now   当前接收文件大小
     * @param total 接收文件总大小
     * 文件传输时发送信号
     */
    void onGettingFile(quint32 now,quint32 total);

private:
    QTcpServer *tcpServer;
};

#endif // FILESERVER_H
